(c) 2007, DHTML-Menu.com
 
   
   
  Support
  Recent Questions
  Write To Support
 

    I have 25 images on one page. I want to use it's own popup javascript context menu for each image.

Return to Recent Questions


Q: I have 25 icons (images) on one page. I want to use it's own popup javascript context menu for each image.
How and where do I define IDs number 2-24 ?
Obviously I now have the first javascript context menu working only.
Does each image need it's own "source_" file?

Also, where is it defined that the popup javascript context menu has ID 1 ?


A: > Also, where is it defined that the popup javascript context menu has ID 1 ?

Each javascript context menu has ID. The ID's number starts with 0.

So, when you have several data files on your page you have such ID's:

<script type="text/javascript" language="JavaScript1.2" src="menu-top.js"></script> // ID - 0

<script type="text/javascript" language="JavaScript1.2" src="source_pop.js"></script> // ID - 1

<script type="text/javascript" language="JavaScript1.2" src="source_pop1.js"></script> // ID - 2

<script type="text/javascript" language="JavaScript1.2" src="source_pop2.js"></script> // ID - 3

<script type="text/javascript" language="JavaScript1.2" src="source_pop3.js"></script> // ID - 4

and so on.

> I have 25 icons (images) on one page. I want to use it's own popup javascript context menu for each image.
If you want to have different style for the popup menus (there color, item, text, font and so on) you should create 25 different .js files with your parameters. And call them from your page, for example:

<SCRIPT language=JavaScript1.2 src="source_pop.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript1.2 src="source_pop1.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript1.2 src="source_pop2.js" type=text/javascript></SCRIPT>
...
<SCRIPT language=JavaScript1.2 src="source_pop24.js" type=text/javascript></SCRIPT>

If you have different item text only you can use one .js file with javascript context menu parameters:
<SCRIPT language=JavaScript1.2 src="source_pop.js" type=text/javascript></SCRIPT>
But you should delete the following code:

var menuItems = [

["Next","testlink.htm"],
["Prev","testlink.htm"],
["Close","testlink.htm"],
];

dm_init();

and move it to the html page:

<body>
...
<SCRIPT language=JavaScript1.2 src="source_pop.js" type=text/javascript></SCRIPT>
<script type="text/javascript"> //first popup javascript context menu ID - 1
var menuItems = [

["Next","testlink.htm"],
["Prev","testlink.htm"],
["Close","testlink.htm"],
];

dm_init();
</SCRIPT>
<script type="text/javascript"> //second popup menu ID - 2
var menuItems = [

["Text","testlink.htm"],
["Text1","testlink.htm"],
["Text2","testlink.htm"],
];

dm_init();
</SCRIPT>
<script type="text/javascript"> //third popup menu ID - 3
var menuItems = [

["New_Text","testlink.htm"],
["New_Text1","testlink.htm"],
["New_Text2","testlink.htm"],
];

dm_init();
</SCRIPT>
...
<script type="text/javascript"> //twenty fourth popup menu ID - 3
var menuItems = [

["New","testlink.htm"],
["New","testlink.htm"],
["New","testlink.htm"],
];

dm_init();
</SCRIPT>

And specify OnClick events for your images: <img src="testimage.gif" width=200 onClick="return dm_popup(1, 1000, event);" style="cursor: hand;">
<img src="testimage.gif" width=200 onClick="return dm_popup(2, 1000, event);" style="cursor: hand;">
<img src="testimage.gif" width=200 onClick="return dm_popup(3, 1000, event);" style="cursor: hand;">
...
<img src="testimage.gif" width=200 onClick="return dm_popup(24, 1000, event);" style="cursor: hand;">
...
</body>






Return to Recent Questions

   
Copyright (c) 2012, DHTML-Menu.com
Home  |  Product Info  |  Samples  |  Download  |  Purchase  |  FAQ  |  Site Map  |  Write Us
All rights reserved. free website generator | bootstrap popup window | bootstrap forms | HTML5 Video Player | css slider